
import controlP5.*;
import swidgets.*;


ControlP5 cp5;
SWDisplayWords sdw;
Textfield ctx;


void setup() {
  size(400,400);
  
  PApplet theParent;
  theParent = this;
  
  cp5 = new ControlP5(this);
  smooth();
  
  ctx = cp5.addTextfield("textinput")
      	   .setPosition(100, 200)
           .setSize(200, 20)
           .setFocus(true)
           .setCaptionLabel("Integer");
           ;
           
  ctx.setInputFilter(ControlP5.INTEGER);           

  cp5.addButton("bang1")
     .setValue(0)
     .setPosition(320,200)
     .setSize(35,35)
     .setCaptionLabel("set")
     ;
       
  sdw = new SWDisplayWords(cp5,theParent);
  sdw.setPosition(100,100);
  sdw.setTempo(90, 1);
  	  
  PFont font = createFont("",40);
  textFont(font);
}

// Button 'bang1' callback...
void bang1(int bangVal) {
  String ss = ctx.getText();
  if(ss.length() > 0) {
  	sdw.setTempo(float(ss), 1);
  } 
}

void draw() {
  background(176,196,222); 
  sdw.render();
}
